package main

import (
    "facecat"
    "io/ioutil"
    "fmt"
)

 /*
* 点击单元格
* grid:表格
* row:行
* column:列
* cell:单元格
* firstTouch:是否第一次触摸
* firstPoint:第一次触摸的坐标
* secondTouch:是否第二次触摸
* secondPoint:第二次触摸的坐标
* clicks:点击次数
*/
func OnClickGridCell(grid *facecat.FCView, row *facecat.FCGridRow, column *facecat.FCGridColumn, cell *facecat.FCGridCell, firstTouch bool, firstPoint facecat.FCPoint, secondTouch bool, secondPoint facecat.FCPoint, clicks int){
    fmt.Println(cell.Value)
}

var gPaint = facecat.CreatePaint()

func WndProc(hwnd facecat.HWND, msg uint32, wParam, lParam uintptr) (result uintptr) {
    return facecat.WndProcDefault(gPaint, hwnd, msg, wParam, lParam)
}

func main() {
    gPaint.OnClickGridCell = OnClickGridCell
    facecat.CreateMainWindow(gPaint, "FaceCat-Go", WndProc)
    xmlStr, _ := ioutil.ReadFile("xml//gridexample.xml")
    facecat.RenderFaceCat(gPaint, string(xmlStr))
    grid := facecat.FindViewByName("Grid", gPaint.Views)
    for i := 0; i < 100; i++{
        row := facecat.CreateGridRow()
        grid.GetGrid().Rows = append(grid.GetGrid().Rows, row)
        for j := 0; j < 3; j++{
            cell := facecat.CreateGridCell()
            cell.Value = "Cell" + facecat.ConvertIntToStr(i)
            row.Cells = append(row.Cells, cell)
        }
    }
    facecat.Invalidate(gPaint)
    facecat.ShowWindow(gPaint)
}